package net.csdn.business.common.domain;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;

import java.io.Serializable;


/**
 * @Author: zhangyl
 * @Description:
 * @DateTime: 2022/6/16 7:49 下午
 * @Params:
 * @Return
 */
@Getter
public abstract class SuperPageQueryDTO<T> implements Serializable {

    /**
     * 页码
     */
    protected Integer pageNum = 1;

    /**
     * 每页大小
     */
    protected Integer pageSize = 10;


    public Page<T> getPage() {
        Page<T> pagination = new Page<>(pageNum, pageSize);
        return pagination;
    }

    /**
     * fix 23.02.01 jackson deserialize Exception
     *
     * @param pageNum 页码
     */
    @JsonIgnore
    public void setPage(Integer pageNum) {
        if (pageNum != null) {
            this.pageNum = pageNum;
        }
    }

    public Integer getSize() {
        return pageSize;
    }

    public void setSize(Integer size) {
        if (size != null) {
            this.pageSize = size;
        }
    }
}